package leetcode.linkedlist;

import leetcode.linkedlist.common.LinkedListUtils;
import leetcode.linkedlist.common.ListNode;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 * int val;
 * ListNode next;
 * ListNode() {}
 * ListNode(int val) { this.val = val; }
 * ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution24 {
    public ListNode swapPairs(ListNode head) {
        return LinkedListUtils.swapPairs(head);
    }
}

public class leetcode24 {
    public static void main(String[] args) {
        Solution24 solution24 = new Solution24();
        int[] nums1 = {1};
        int[] nums2 = {1, 2};
        int[] nums3 = {1, 2, 3};
        int[] nums4 = {1, 2, 3, 4};
        int[] nums5 = {1, 2, 3, 4, 5};
        int[] nums6 = {1, 2, 3, 4, 5, 6};
        int[] nums7 = {1, 2, 3, 4, 5, 6, 7};
        int[] nums8 = {1, 2, 3, 4, 5, 6, 7, 8};
        test24(solution24, nums1);
        test24(solution24, nums2);
        test24(solution24, nums3);
        test24(solution24, nums4);
        test24(solution24, nums5);
        test24(solution24, nums6);
        test24(solution24, nums7);
        test24(solution24, nums8);
    }

    private static void test24(Solution24 solution24, int[] nums) {
        System.out.println(LinkedListUtils.getLinkedListVals(solution24.swapPairs(LinkedListUtils.generateLinkedListByArray(nums))));
    }
}
